package com.project.baowei.prsenter;

import com.project.baowei.bean.request.VerifyRequest;
import com.project.baowei.bean.respoes.LoginBean;
import com.project.baowei.bean.respoes.VerifyBean;
import com.project.baowei.contract.HomeContract;
import com.project.baowei.contract.LoginContract;
import com.project.baowei.net.NetUtils;
import com.wangshen.base.net.bean.BaseAppEntity;
import com.wangshen.base.ui.mvp.base.presenter.BasePresenter;

import io.reactivex.functions.Consumer;

public class HomePresenter extends BasePresenter<HomeContract.View> implements HomeContract.Presenter {

    @Override
    public void verify(VerifyRequest body) {
        NetUtils.geApi().verify(body)
                .compose(this.handleEverythingResult())
                .subscribe(new Consumer<BaseAppEntity<VerifyBean>>() {
                    @Override
                    public void accept(BaseAppEntity<VerifyBean> loginBeanBaseAppEntity) throws Exception {
                       // getView().showMessage(loginBeanBaseAppEntity.getMessage());
                        getView().setData(loginBeanBaseAppEntity.getData());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        getView().showMessage(throwable.getMessage());
                    }
                });
    }
}
